import { defineStore } from "pinia";
import { ref } from "vue";
/**
 * 用户信息 
 */
export const useUserStore = defineStore(
  "user",
  () => {
    const userInfo = ref({});
    const token = ref("");
    const isLogin = ref(false);
    const login = (data: any) => {
      userInfo.value = data;
      token.value = data.token;
      isLogin.value = true;
    };
    const logout = () => {
      userInfo.value = {};
      token.value = "";
      isLogin.value = false;
    };

    return {
      userInfo,
      token,
      isLogin,
      login,
      logout,
    };
  },
  {}
);
